package com.hongsen.cn.activity;

import android.view.LayoutInflater;
import android.view.View;

import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.hongsen.cn.Utils.ToastUtils;
import com.hongsen.cn.adapter.GetOutOfLineAdapter;
import com.hongsen.cn.base.BaseActivity;
import com.hongsen.cn.bean.TheKeyPersonelBean;
import com.hongsen.cn.contract.OutOfLinePresenter;
import com.hongsen.cn.dayandmonth.R;
import com.hongsen.cn.dayandmonth.databinding.ActivityOutBinding;
import com.hongsen.cn.listener.OnItemClickListener;
import com.hongsen.cn.presenter.OutOfLineView;

import java.util.List;

public class GetOutOfLineActivity extends BaseActivity<OutOfLinePresenter> implements OutOfLineView {

    public ActivityOutBinding binding;

    @Override
    protected OutOfLinePresenter createPresenter() {
        return new OutOfLinePresenter(GetOutOfLineActivity.this);
    }


    @Override
    protected void initData() {
        binding.tvEvaluation.setText("江南");
        presenter.getTheKeyPersonel("3");
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.activity_out,null,false);
        binding.setActivity(this);
        baseFl.addView(binding.getRoot());
    }

    @Override
    public void getTheKeyPersonel(String type, final List<TheKeyPersonelBean> list) {
        binding.rlModule.setLayoutManager(new LinearLayoutManager(GetOutOfLineActivity.this));
        binding.rlModule.setItemAnimator(new DefaultItemAnimator());
        GetOutOfLineAdapter adapter = new GetOutOfLineAdapter(GetOutOfLineActivity.this, list,"1");
        binding.rlModule.setAdapter(adapter);
        adapter.setOnItemClickLitener(new OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                ToastUtils.showShort(list.get(position).getDetaineesName());
            }

            @Override
            public void onItemLongClick(View view, int position) {

            }
        });
    }
}
